package org.distributed.transaction.core.process;

import org.distributed.transaction.core.adapter.TransactionProcessorAdapter;
import org.distributed.transaction.core.context.TransactionContext;
import org.distributed.transaction.core.exception.TransactionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Proxy模式，分布式事务已经正在运行时候的处理器
 *
 */
@Component
public class ProxyRunningTransactionProcessor implements TransactionProcessor{

	@Autowired
	private TransactionProcessorAdapter transactionProcessorAdapter;
	
	@Override
	public void preBusinessCode(TransactionContext transactionContext) throws TransactionException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onBusinessCodeError(TransactionContext transactionContext, Throwable throwable)
			throws TransactionException {
		
	}

	@Override
	public void onBusinessCodeSuccess(TransactionContext transactionContext, Object result)
			throws TransactionException {
		transactionProcessorAdapter.joinGroup(transactionContext);
	}

	@Override
	public void clear(TransactionContext transactionContext) {
		
	}

}
